import React, { Component, Fragment } from 'react';
import ContainerWrapper from '@/components/ContainerWrapper';
import { Card, Table } from 'antd';
import { connect } from 'dva';
import SearchContainer from '@/myComponents/SearchContainer';

const style = {
   mr10: {
      marginRight: '10px'
   },
   mt40: {
      marginTop: '40px'
   }
}

@connect(({ knowFlow, menu }) => ({
   knowFlow,
   menu
}))
class Purchase extends Component {
   componentDidMount() {
      this.fetchData()
   }
   // 获取数据
   fetchData = () => {
      const { dispatch } = this.props;
      dispatch({
         type: 'knowFlow/fetch',
      });
   }
   // 触发搜索
   handleSearch = data => {
      console.log('获取数据', data)
   }
   // 触发导出操作
   handleExport = () => {
      const { knowFlow } = this.props;
      console.log('导出', knowFlow);
   }
   render() {
      const { knowFlow: { purchase: { data, columns } } } = this.props;
      return (
         <ContainerWrapper>
            <Card bordered={false}>
               <SearchContainer emitSearch={(data)=>this.handleSearch(data)} emitExport={this.handleExport}/>
               <Table style={style.mt40} columns={columns} dataSource={data} />
            </Card>
         </ContainerWrapper>
      );
   }
}

export default Purchase;
